<template>
   <div>
    <el-row justify="space-between">
      <el-col :span="4" class="grid-content ep-bg-purple-dark">
        <div class="logo">
          <img src="../../../../assets/login-images/data/icon01.png" alt="" />
          <div class="right">
            <p>新增加收益</p>
            <div class="price">
              1627
              <span>¥</span>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="4" class="grid-content ep-bg-purple-dark">
        <div class="logo">
          <img src="../../../../assets/login-images/data/icon02.png" alt="" />
          <div class="right">
            <p>新订单量</p>
            <div class="price">
              435
              <span>¥</span>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="4" class="grid-content ep-bg-purple-dark">
        <div class="logo">
          <img src="../../../../assets/login-images/data/icon03.png" alt="" />
          <div class="right">
            <p>昨日总收益</p>
            <div class="price">
              1627
              <span>¥</span>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="4" class="grid-content ep-bg-purple-dark">
        <div class="logo">
          <img src="../../../../assets/login-images/data/icon04.png" alt="" />
          <div class="right">
            <p>待处理订单</p>
            <div class="price">
              537
              <span>¥</span>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="5" class="grid-content ep-bg-purple-dark">
        <div class="logo">
          <img src="../../../../assets/login-images/data/icon05.png" alt="" />
          <div class="right">
            <p>年度累计收益</p>
            <div class="price">
              88888
              <span>¥</span>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-row justify="space-between" class="second">
      <el-col :span="12" class="grid-content ep-bg-purple" id="main"> </el-col>
      <el-col :span="5" class="grid-content ep-bg-purple" id="main2"></el-col>
      <el-col :span="6" class="grid-content ep-bg-purple" id="main3"></el-col>
    </el-row>
    <el-row justify="space-between">
      <el-col :span="13" class="grid-content ep-bg-purple2" id="main4"></el-col>
      <el-col :span="10" class="grid-content ep-bg-purple2" id="main5"></el-col>
    </el-row>
  </div>
</template>
<script>
import * as echarts from "echarts";
import { onMounted, onBeforeUnmount } from "vue";
export default {
  setup() {
    let myChart;

    onMounted(() => {
      myChart = echarts.init(document.querySelector("#main"));
      myChart.setOption({
        title: {
          text: "近期成交额",
        },
        xAxis: {
          type: "category",
          data: ["5-13", "5-14", "5-15", "5-16", "5-17", "5-18", "5-19"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [450, 460, 520, 430, 550, 970, 1010],
            type: "line",
            smooth: true,
          },
        ],
      });

      myChart = echarts.init(document.querySelector("#main2"));
      myChart.setOption({
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b}: {c} ({d}%)",
        },
        legend: {
          data: ["收入", "支出"],
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            selectedMode: "single",
            radius: [0, "30%"],
            label: {
              position: "inner",
              fontSize: 14,
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 500, name: "支出" },
              { value: 1000, name: "收入" },
            ],
          },
          {
            name: "Access From",
            type: "pie",
            radius: ["45%", "60%"],
            labelLine: {
              length: 30,
            },
            // label: {
            //   rich: {
            //     a: {
            //       color: "#6E7079",
            //       lineHeight: 22,
            //       align: "center",
            //     },
            //     hr: {
            //       borderColor: "#8C8D8E",
            //       width: "100%",
            //       borderWidth: 1,
            //       height: 0,
            //     },
            //     b: {
            //       color: "#4C5058",
            //       fontSize: 14,
            //       fontWeight: "bold",
            //       lineHeight: 33,
            //     },
            //     per: {
            //       color: "#fff",
            //       backgroundColor: "#4C5058",
            //       padding: [3, 4],
            //       borderRadius: 4,
            //     },
            //   },
            // },
            data: [
              { value: 500, name: "支出" },

              { value: 1000, name: "收入" },
            ],
          },
        ],
      });
      myChart = echarts.init(document.querySelector("#main3"));

      myChart.setOption({
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "5%",
          left: "center",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: "#fff",
              borderWidth: 2,
            },
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "40",
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 600, name: "A品牌" },
              { value: 735, name: "C品牌" },
              { value: 1000, name: "B品牌" },
              { value: 1384, name: "D品牌" },
            ],
          },
        ],
      });
      myChart = echarts.init(document.querySelector("#main4"));
      myChart.setOption({
        title: {
          text: "成交额统计",
        },
        xAxis: {
          type: "category",
          data: ["1月", "2月", "3月", "4月", "5月", "6月"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [300, 820, 800, 934, 1180, 1330, 1650],
            type: "line",
            smooth: true,
          },
        ],
      });
      myChart = echarts.init(document.querySelector("#main5"));
      myChart.setOption({
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            axisLabel: {
              interval: 0,
              textStyle: {
                fontSize: "9",
              },
            },

            type: "category",
            data: [
              "狗粮(国产)",
              "狗粮(进口)",
              "玩具",
              "食盐",
              "梳毛器",
              "电动剃毛器",
              "狗粮",
              "宠物店",
              "磨牙棒",
              "自动喂食器",
            ],
            axisTick: {
              alignWithLabel: true,
            },
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "Direct",
            type: "bar",
            barWidth: "60%",

            data: [900, 780, 620, 615, 612, 580, 540, 450, 410, 400],
          },
        ],
      });
      window.onresize = () => {
        myChart.resize();
      };
    });
    onBeforeUnmount(() => {
      myChart.dispose();
    });
  },
};
</script>
<style lang="less" scoped>
.el-col {
  border-radius: 4px;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.ep-bg-purple-dark {
  height: 150px;
  background: white;
  border-radius: 10px;

  .logo {
    display: flex;
    justify-content: center;
    margin-top: 35px;

    img {
      width: 80px;
      height: 80px;
    }
    .right {
      display: flex;
      flex-direction: column;
      justify-content: center;
      margin-top: 5px;
      margin-left: 3px;

      p {
        height: 24px;
        font-size: 20px;
        font-family: YouYuan;
        text-align: center;
      }

      .price {
        height: 35px;
        font-size: 30px;
        font-family: pingfang sc;
        font-weight: 600;
        text-align: center;
        margin-top: 3px;

        span {
          font-size: 10px;
        }
      }
    }
  }
}
.ep-bg-purple {
  height: 330px;
  background: white;

  .abc {
    width: 200px;
    height: 200px;
  }
}
.ep-bg-purple2 {
  height: 350px;
  background: white;
}
.second {
  margin-top: 20px;
  margin-bottom: 20px;
}
</style>